//username处于焦点时，显示的用户名相关信息
function setusername(){
	nameDiv = document.getElementById("name_check");
	nameDiv.innerHTML = "<img src='../images/default/1000316.gif' align='absmiddle' />&nbsp;&nbsp;由4-20个字母或数字组成。不支持中文，不能以数字开头。";
}

//password处于焦点时，显示的密码相关信息
function setpassword(){
	nameDiv = document.getElementById("password2");
	nameDiv.innerHTML = "<img src='../images/default/1000316.gif' align='absmiddle' />&nbsp;&nbsp;由6-20个字母（区分大小写）或数字组成。";
}

//repassword处于焦点时，显示的重复密码相关信息
function setrepassword(){
	nameDiv = document.getElementById("password3");
	nameDiv.innerHTML = "<img src='../images/default/1000316.gif' align='absmiddle' />&nbsp;&nbsp;请再输入一遍您上面填写的密码。";
}

//code处于焦点时，显示的密码相关信息
function setimage(){
	nameDiv = document.getElementById("codes");
	nameDiv.innerHTML = "<img src='../images/default/1000316.gif' align='absmiddle' />&nbsp;&nbsp;请将图片上的数字准确抄写到左侧文本框中。";
}

function validateform()
{
        if (document.tx1.username.value=="")
        {
                window.alert ("输入会员用户名")
                        return false;
        }
        
        if (document.tx1.password.value=="")
        {
                window.alert ("输入密码")
                        return false;
        }
        if (document.tx1.repassword.value=="")
        {
                window.alert ("再次输入密码")
                        return false;
        }

        if (document.tx1.repassword.value!=document.tx1.password.value)
        {
                window.alert ("2次输入密码不一样")
                        return false;
        }
		if (document.tx1.code.value=="")
		{
				window.alert ("请输入验证码")
					return false;
		}
}

var xmlHttp = createXmlHttpRequestObject();

function createXmlHttpRequestObject(){
	var xmlHttp;
	try{
		xmlHttp = new XMLHttpRequest();
	}
	catch (e){
		var XmlHttpVersions = new Array(
			"MSXML2.XMlHTTP.6.0",
			"MSXML2.XMlHTTP.5.0",
			"MSXML2.XMlHTTP.4.0",
			"MSXML2.XMlHTTP.3.0",
			"MSXML2.XMlHTTP",
			"Microsoft.XMlHTTP");
        for(var i=0;i<XmlHttpVersions.length && !xmlHttp;i++){
			try{
				xmlHttp = new ActiveXObject(XmlHttpVersions[i]);
			}
			catch (e) {}
		}
	}
	if(!xmlHttp)
		alert("Error crearing XMLHttpRequest");
	else
		return xmlHttp;
}

function CallServer_name(){
	var js_name=document.getElementById("username").value;
	if (js_name==""){
                nameDiv = document.getElementById("name_check");
                nameDiv.innerHTML = "<img src='../images/default/1000216.gif' align='absmiddle' />&nbsp;&nbsp;用户名不能为空";
		}else{
			if (js_name.length<4 || js_name.length>20){
						nameDiv = document.getElementById("name_check");
						nameDiv.innerHTML = "<img src='../images/default/1000216.gif' align='absmiddle' />&nbsp;&nbsp;用户名长度要求在4-20位之间";
				}
			else{
						var url ="check-name.php?js_name="+js_name; //UTF-8下要用encodeURI
						xmlHttp.open("GET",url,true);
						xmlHttp.onreadystatechange=handleRequestStateChange_name;
						xmlHttp.send(null);
				}
			}

}
function handleRequestStateChange_name()
{
        nameDiv = document.getElementById("name_check");
        if(xmlHttp.readyState < 4)
        {
        //        nameDiv.innerHTML = "loading...<br/>";

        }
                else         if(xmlHttp.readyState == 4)
                {
                        if(xmlHttp.status == 200)
                        {
                                
                                try
                                {
                                nameDiv.innerHTML=xmlHttp.responseText;
                                }
                                catch (e)
                                {
                                        alert("error" + e.toString());
                                }
                        }
                        else
                        {
                                alert("problrm" + e.toString());
                        }
                }
}


function CallServer_email()
{
        
var js_email=document.getElementById("js_email").value;
        if (js_email!="")
        {
        //        myDiv = document.getElementById("email_check");
        //        myDiv.innerHTML = "js_name";
var url ="check-email.php?js_email="+js_email; //UTF-8下要用encodeURI
xmlHttp.open("GET",url,true);
xmlHttp.onreadystatechange=handleRequestStateChange_email;
xmlHttp.send(null);
        }else
        {
                myDiv = document.getElementById("email_check");
                myDiv.innerHTML = "email were not empty";
        //alert("请您填写用户名！");
        }

}






function handleRequestStateChange_email()
{
//        alert("请您填写用户名！");
        myDiv = document.getElementById("email_check");
        if(xmlHttp.readyState < 4)
        {
        //        myDiv.innerHTML = "loading...<br/>";

        }
                else         if(xmlHttp.readyState == 4)
                {
                        if(xmlHttp.status == 200)
                        {
                                
                                try
                                {
                                myDiv.innerHTML=xmlHttp.responseText;
                                }
                                catch (e)
                                {
                                        alert("error" + e.toString());
                                }
                        }
                        else
                        {
                                alert("problrm" + e.toString());
                        }
                }
}




function checkpass1()
  {
    var Inform="tx1";
var Inputname="repassword";
    var Form=Inform+"."
    eval("Temp="+Form+Inputname+".value;"); 
//alert(Temp);
if(Temp==""){ 
msg="<img src='../images/default/1000216.gif' align='absmiddle' />&nbsp;&nbsp;此项不能为空"; 
}
else
{  
      if(Temp.length<6||Temp.length>20)
   {
     msg="<img src='../images/default/1000216.gif' align='absmiddle' />&nbsp;&nbsp;密码必须在6~20个字符之间";
   }
   else
   {
  var Inputname1="password";
     eval("Temp1="+Form+Inputname1+".value");
  if (Temp!=Temp1)
  {
          eval(Form+Inputname+".value='';");
    eval(Form+Inputname1+".value='';");
    eval(Form+Inputname1+".focus();");
    msg="<img src='../images/default/1000216.gif' align='absmiddle' />&nbsp;&nbsp;两次密码不一样！"; 
    msg1="";
    var ch1=document.getElementById("password2");
    ch1.innerHTML=msg1;
  }
  else
  {
    msg="<img src='../images/default/1000716.gif' align='absmiddle' />&nbsp;&nbsp;输入正确";
  }
   }
}
var ch=document.getElementById("password3");
ch.innerHTML=msg; 
  }
  
  
function checkpass()
  {
    var Inform="tx1";
var Inputname="password";
    var Form=Inform+"."
    eval("Temp="+Form+Inputname+".value;"); 
//alert(Temp);
if(Temp==""){ 
msg="<img src='../images/default/1000216.gif' align='absmiddle' />&nbsp;&nbsp;密码不能为空"; 
}
else
{  
      if(Temp.length<6||Temp.length>20)
   {
     msg="<img src='../images/default/1000216.gif' align='absmiddle' />&nbsp;&nbsp;密码必须在6~20个字符之间";
   }
   else
   {
     msg="<img src='../images/default/1000716.gif' align='absmiddle' />&nbsp;&nbsp;输入正确";
   }
}
var ch=document.getElementById("password2");
ch.innerHTML=msg;
  }

function checkname(){
	var name=document.getElementById("name").value;
	if (name==""){
		nameDiv = document.getElementById("names");
		nameDiv.innerHTML = "<img src='../images/default/1000216.gif' align='absmiddle' />&nbsp;&nbsp;请填写您的姓名";
		}
	else{
		nameDiv = document.getElementById("names");
		nameDiv.innerHTML = "<img src='../images/default/1000716.gif' align='absmiddle' />&nbsp;&nbsp;输入正确";
		}

	}




function CallServer_code(){
	var code=document.getElementById("code").value;
	if (code==""){
                nameDiv = document.getElementById("codes");
                nameDiv.innerHTML = "<img src='../images/default/1000216.gif' align='absmiddle' />&nbsp;&nbsp;请填写验证码";
		}else{
			if (code.length!=4){
						nameDiv = document.getElementById("codes");
						nameDiv.innerHTML = "<img src='../images/default/1000216.gif' align='absmiddle' />&nbsp;&nbsp;填写错误";
				}
			else{
						var url ="check-image.php?code="+code; //UTF-8下要用encodeURI
						xmlHttp.open("GET",url,true);
						xmlHttp.onreadystatechange=handleRequestStateChange_code;
						xmlHttp.send(null);
				}
			}

}
function handleRequestStateChange_code()
{
        nameDiv = document.getElementById("codes");
        if(xmlHttp.readyState < 4)
        {
        //        nameDiv.innerHTML = "loading...<br/>";

        }
                else         if(xmlHttp.readyState == 4)
                {
                        if(xmlHttp.status == 200)
                        {
                                
                                try
                                {
                                nameDiv.innerHTML=xmlHttp.responseText;
                                }
                                catch (e)
                                {
                                        alert("error" + e.toString());
                                }
                        }
                        else
                        {
                                alert("problrm" + e.toString());
                        }
                }
}




//省市县三级联动菜单
function change_province(){
    nameCounty=document.getElementById("countys");
	nameCounty.innerHTML="<select name=county id=county style='width:246px'><option value=''>县级单位</option></select>";
	var province=document.getElementById("province").value;
	if (province==""){
				nameDiv = document.getElementById("citys");
				nameDiv.innerHTML = "<select name=city id=city style='width:246px'><option value=''>市级单位</option></select>";
		}else{
				var url ="change-province.php?province="+province; //UTF-8下要用encodeURI
				xmlHttp.open("GET",url,true);
				xmlHttp.onreadystatechange=handleRequestStateChange_province;
				xmlHttp.send(null);
			}

}
function handleRequestStateChange_province()
{
        nameDiv = document.getElementById("citys");
        if(xmlHttp.readyState < 4)
        {
        //        nameDiv.innerHTML = "loading...<br/>";

        }
                else         if(xmlHttp.readyState == 4)
                {
                        if(xmlHttp.status == 200)
                        {
                                
                                try
                                {
                                nameDiv.innerHTML=xmlHttp.responseText;
                                }
                                catch (e)
                                {
                                        alert("error" + e.toString());
                                }
                        }
                        else
                        {
                                alert("problrm" + e.toString());
                        }
                }
}
function change_city(){
	var city=document.getElementById("city").value;
	if (city==""){
                nameDiv = document.getElementById("countys");
				nameDiv.innerHTML = "<select name=county id=county onchange='change_city()' style='width:246px'><option value=''>县级单位</option></select>";
		}else{
				var url ="change-city.php?city="+city; //UTF-8下要用encodeURI
				xmlHttp.open("GET",url,true);
				xmlHttp.onreadystatechange=handleRequestStateChange_city;
				xmlHttp.send(null);
			}

}
function handleRequestStateChange_city()
{
        nameDiv = document.getElementById("countys");
        if(xmlHttp.readyState < 4)
        {
        //        nameDiv.innerHTML = "loading...<br/>";

        }
                else         if(xmlHttp.readyState == 4)
                {
                        if(xmlHttp.status == 200)
                        {
                                
                                try
                                {
                                nameDiv.innerHTML=xmlHttp.responseText;
                                }
                                catch (e)
                                {
                                        alert("error" + e.toString());
                                }
                        }
                        else
                        {
                                alert("problrm" + e.toString());
                        }
                }
}



//退出系统
function exitsys(){
    var ask=confirm("你确定要退出吗？");
    if(ask)
	{
        top.location.href="quit.php?flg=2";
    }
}
//注销
function logout(){
    var ask=confirm("你确定注销吗？\n");
    if(ask)
	{
        top.location.href="quit.php?flg=1";
    }
}

//省市三级联动菜单  出发地
function change_sprovince(){
    nameCounty=document.getElementById("scountys");
	nameCounty.innerHTML="<select name=scounty id=scounty style='width:208px'><option value=''>全市</option></select>";
	var province=document.getElementById("sprovince").value;
	if (province==""){
				nameDiv = document.getElementById("scitys");
				nameDiv.innerHTML = "<select name=scity id=scity style='width:208px'><option value=''>全省</option></select>";
		}else{
				var url ="change-sprovince.php?province="+province; //UTF-8下要用encodeURI
				xmlHttp.open("GET",url,true);
				xmlHttp.onreadystatechange=handleRequestStateChange_sprovince;
				xmlHttp.send(null);
			}

}
function handleRequestStateChange_sprovince()
{
        nameDiv = document.getElementById("scitys");
        if(xmlHttp.readyState < 4)
        {
        //        nameDiv.innerHTML = "loading...<br/>";

        }
                else         if(xmlHttp.readyState == 4)
                {
                        if(xmlHttp.status == 200)
                        {
                                
                                try
                                {
                                nameDiv.innerHTML=xmlHttp.responseText;
                                }
                                catch (e)
                                {
                                        alert("error" + e.toString());
                                }
                        }
                        else
                        {
                                alert("problrm" + e.toString());
                        }
                }
}
function change_scity(){
	var city=document.getElementById("scity").value;
	if (city==""){
                nameDiv = document.getElementById("scountys");
				nameDiv.innerHTML = "<select name=scounty id=scounty style='width:208px'><option value=''>全市</option></select>";
		}else{
				var url ="change-scity.php?city="+city; //UTF-8下要用encodeURI
				xmlHttp.open("GET",url,true);
				xmlHttp.onreadystatechange=handleRequestStateChange_scity;
				xmlHttp.send(null);
			}

}
function handleRequestStateChange_scity()
{
        nameDiv = document.getElementById("scountys");
        if(xmlHttp.readyState < 4)
        {
        //        nameDiv.innerHTML = "loading...<br/>";

        }
                else         if(xmlHttp.readyState == 4)
                {
                        if(xmlHttp.status == 200)
                        {
                                
                                try
                                {
                                nameDiv.innerHTML=xmlHttp.responseText;
                                }
                                catch (e)
                                {
                                        alert("error" + e.toString());
                                }
                        }
                        else
                        {
                                alert("problrm" + e.toString());
                        }
                }
}
//省市三级联动菜单  目的地
function change_rprovince(){
    nameCounty=document.getElementById("rcountys");
	nameCounty.innerHTML="<select name=rcounty id=rcounty style='width:208px'><option value=''>全市</option></select>";
	var province=document.getElementById("rprovince").value;
	if (province==""){
				nameDiv = document.getElementById("rcitys");
				nameDiv.innerHTML = "<select name=rcity id=rcity style='width:208px'><option value=''>全省</option></select>";
		}else{
				var url ="change-rprovince.php?province="+province; //UTF-8下要用encodeURI
				xmlHttp.open("GET",url,true);
				xmlHttp.onreadystatechange=handleRequestStateChange_rprovince;
				xmlHttp.send(null);
			}

}
function handleRequestStateChange_rprovince()
{
        nameDiv = document.getElementById("rcitys");
        if(xmlHttp.readyState < 4)
        {
        //        nameDiv.innerHTML = "loading...<br/>";

        }
                else         if(xmlHttp.readyState == 4)
                {
                        if(xmlHttp.status == 200)
                        {
                                
                                try
                                {
                                nameDiv.innerHTML=xmlHttp.responseText;
                                }
                                catch (e)
                                {
                                        alert("error" + e.toString());
                                }
                        }
                        else
                        {
                                alert("problrm" + e.toString());
                        }
                }
}
function change_rcity(){
	var city=document.getElementById("rcity").value;
	if (city==""){
                nameDiv = document.getElementById("rcountys");
				nameDiv.innerHTML = "<select name=rcounty id=rcounty style='width:208px'><option value=''>全市</option></select>";
		}else{
				var url ="change-rcity.php?city="+city; //UTF-8下要用encodeURI
				xmlHttp.open("GET",url,true);
				xmlHttp.onreadystatechange=handleRequestStateChange_rcity;
				xmlHttp.send(null);
			}

}
function handleRequestStateChange_rcity()
{
        nameDiv = document.getElementById("rcountys");
        if(xmlHttp.readyState < 4)
        {
        //        nameDiv.innerHTML = "loading...<br/>";

        }
                else         if(xmlHttp.readyState == 4)
                {
                        if(xmlHttp.status == 200)
                        {
                                
                                try
                                {
                                nameDiv.innerHTML=xmlHttp.responseText;
                                }
                                catch (e)
                                {
                                        alert("error" + e.toString());
                                }
                        }
                        else
                        {
                                alert("problrm" + e.toString());
                        }
                }
}



//设置专线信息二级联动
function line_sprovince(){
	var province=document.getElementById("sprovince").value;
	var url ="change-sline.php?province="+province; //UTF-8下要用encodeURI
	xmlHttp.open("GET",url,true);
	xmlHttp.onreadystatechange=handleRequestStateChange_sprovince;
	xmlHttp.send(null);
}
function line_rprovince(){
	var province=document.getElementById("rprovince").value;
	var url ="change-rline.php?province="+province; //UTF-8下要用encodeURI
	xmlHttp.open("GET",url,true);
	xmlHttp.onreadystatechange=handleRequestStateChange_rprovince;
	xmlHttp.send(null);
}
//发布车辆时是否显示选择地区信息
function showArea(){
	option=document.getElementById("option");
	if (option.value==""){
		area.style.display="";
	}
	else {
		area.style.display="none";
	}
}
//发布车辆时选择专线或区域
function showLine($sure){
	if ($sure=='line'){
		line.style.display="";
		area.style.display="none";
	}else{
		line.style.display="none";
		area.style.display="";
	}
}
//选择身份类型，显示不同信息填写项
function showIdentity(){
	kind=document.getElementById('kind').value;
	if (kind=='D' || kind=='C' || kind=='P'){
		person.style.display='';
		firm.style.display='none';
	}else if (kind=='F' || kind=='L'){
		person.style.display='none';
		firm.style.display='';
	}else{
		person.style.display='none';
		firm.style.display='none';
	}
}
